function [PQ, status, scheduledTargets] = SCP_ScheduleRun_GRASP(PQ, s1OlTargets, s1OlBins, s2OlTargets, s2OlBins, max_iterations)
%SCP_ScheduleRun_GRASP Summary of this function goes here
%   Detailed explanation goes here

bestScheduledTargets = [];
bestScheduledPriorities = [];
status = 0;

for k = 1:max_iterations
  scheduledTargets = [];
  scheduledPriorities = [];
  
  [scheduledTargets, scheduledPriorities, status] = SCP_Construction(PQ, s1OlTargets, s1OlBins, s2OlTargets, s2OlBins, scheduledTargets, scheduledPriorities);
  if ~status
    continue;
  end
  
  [scheduledTargets, scheduledPriorities, status] = SCP_LocalSearch(PQ, s1OlTargets, s1OlBins, s2OlTargets, s2OlBins, scheduledTargets, scheduledPriorities);
  if ~status
    continue;
  end
  
  [bestScheduledTargets, bestScheduledPriorities, status] = GRASP_UpdateSolution(PQ, bestScheduledTargets, bestScheduledPriorities, scheduledTargets, scheduledPriorities);
  if ~status
    continue;
  end
end

% Sort the scheduled targets by consulting the target lists per sensor
% for node1 = 1:size(bestScheduledTargets, 2)-1
%   for node2 = node1+1:size(bestScheduledTargets, 2)
%     s1Row1 = s1OlBins(s1OlTargets == bestScheduledTargets(node1));
%     s1Row2 = s1OlBins(s1OlTargets == bestScheduledTargets(node2));
%     
%     s2Row1 = s2OlBins(s2OlTargets == bestScheduledTargets(node1));
%     s2Row2 = s2OlBins(s2OlTargets == bestScheduledTargets(node2));
%     
%     if (s1Row2 < s1Row1) || (s2Row2 < s2Row1)
%       temp = bestScheduledTargets(node1);
%       bestScheduledTargets(node1) = bestScheduledTargets(node2); %#ok<AGROW>
%       bestScheduledTargets(node2) = temp; %#ok<AGROW>
%       
%       temp = bestScheduledPriorities(node1);
%       bestScheduledPriorities(node1) = bestScheduledPriorities(node2); %#ok<AGROW>
%       bestScheduledPriorities(node2) = temp; %#ok<AGROW>
%     end
%   end
% end

if ~status
  scheduledTargets = [];
else
  scheduledTargets = ST_TrimZeroes(bestScheduledTargets);
  status = GRASP_CheckSolution(scheduledTargets, s1OlTargets, s1OlBins);
  if ~status
    scheduledTargets = [];
  end
  status = GRASP_CheckSolution(scheduledTargets, s2OlTargets, s2OlBins);
  if ~status
    scheduledTargets = [];
  end
end
end %function